package com.it.selfAfter.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsAutoIncrement;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsKey;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;


import javax.persistence.*;
import java.util.Date;

/**
 * @Author: Coke
 * @DateTime: 2023/05/25/20:27
 * @注释: 作品实体类
 **/
@Data
@Entity
@TableName ("production")
@Table (name = "production", comment = "作品信息")//设置表名  注释
public class Production {

    private static final long serialVersionUID = 9435278593475931L;

    @IsAutoIncrement   //自增
    @IsKey             //主键
    @TableId ( value = "id", type = IdType.AUTO)
    @Id
    @Column (comment = "ID")//字段注释
    private Long id;

    /**
     * 创建时间
     */

    @Column(name = "create_time", type = MySqlTypeConstant.TIMESTAMP, comment = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date create_time;

    /**
     * 修改时间
     */
    @Column(name = "update_time", type = MySqlTypeConstant.TIMESTAMP, comment = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date update_time;

    /**
     * 联系手机
     */
    @Column(name = "phone",comment = "联系手机", length = 255)
    private String phone;

    /**
     * 作品名称
     */
    @Column(name = "name",comment = "作品名称", length = 255)
    private String name;

    /**
     * 是否删除 0 否  1是
     */
    @Column(name = "deleted",comment = "是否删除", defaultValue = "0", length = 10)
    private String deleted;

    /**
     * 创建人
     */
    @Column(name = "create_user",comment = "创建人", length = 255)
    private String create_user;

    /**
     * 发布区域
     */
    @Column(name = "area",comment = "发布区域", length = 255)
    private String area;

    /**
     * 发布详细地址
     */
    @Column(name = "address",comment = "发布详细地址", length = 255)
    private String address;


    /**
     * 作品状态  0 正常 1 取消
     */
    @Column(name = "status",comment = "作品状态  0 正常 1 取消", defaultValue = "0", length = 10)
    private String status;


    /**
     * 作品类型
     */
    @Column(name = "production_type",comment = "作品类型", length = 255)
    private String production_type;

    /**
     * 发布人id
     */
    @Column(name = "user_id",comment = "发布人id", length = 255)
    private String user_id;

    /**
     * 作品描述
     */
    @Column(name = "description",comment = "作品描述", type = MySqlTypeConstant.TEXT)
    private String description;


    /**
     * 作品照片
     */
    @Column(name = "imgs",comment = "作品照片", type = MySqlTypeConstant.TEXT)
    private String imgs;

    /**
     * 新增数据时自动添加时间
     */
    @PrePersist
    protected void onCreate() {
        create_time = new Date();
    }

    /**
     * 更新数据时自动更新时间
     */
    @PreUpdate
    protected void onUpdate() {
        update_time = new Date();
    }
}
